home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.07.lha / AmiCAD / ARexx / Aligner.AmiCAD < prev    next >
Text File  |  2000-11-11  |  3KB  |  86 lines

  1. /* Alignement des éléments sélectionnés */
  2. /* Version 1.0: 23 mai 1998
  3.    Version 1.01: 13 avril 2000 (modif SAVEALL, ajout nom script en cas d'erreur)
  4.    Version 1.02: 3 novembre 2000 (localisation anglais/français)
  5. $VER: Aligner.AmiCAD 1.02 (© R.Florac, 3 novembre 2000) */
  6. /* Ne gère correctement que les éléments du même type */
  7.  
  8. options results     /* indispensable pour récupérer le résultat des macros */
  9.  
  10. signal on error     /* pour l'interception des erreurs */
  11. signal on syntax
  12.  
  13. 'LANGUAGE'
  14. if result='français.language' then fr=1
  15. else fr=0
  16.  
  17. 'NEXTSEL(FIRSTSEL)'
  18. if result=0 then do
  19.     if fr=1 then 'MESSAGE("Sélectionnez au moins"+CHR(10)+"deux éléments avant"+CHR(10)+"d''appeler ce script")'
  20.     else 'MESSAGE("Select two objects"+CHR(10)+"or more before"+CHR(10)+"calling this script")'
  21.     exit
  22. end
  23.  
  24. if fr=1 then 'ALIGNEMENT=SELECT("Alignement"+CHR(10)+"En haut"+CHR(10)+"En bas"+CHR(10)+"À gauche"+CHR(10)+"À droite")'
  25. else 'ALIGNEMENT=SELECT("Alignement"+CHR(10)+"Top"+CHR(10)+"Bottom"+CHR(10)+"Left"+CHR(10)+"Right")'
  26. alignement=result
  27. select
  28.     when alignement=1 then ligne_base=50000
  29.     when alignement=2 then ligne_base=0
  30.     when alignement=3 then colonne_base=50000
  31.     when alignement=4 then colonne_base=0
  32.     otherwise exit
  33. end
  34.  
  35. objets=0
  36. 'FIRSTSEL'; i=result
  37. do while i>0
  38.     objets=objets+1
  39.     'LINE('i')'; ligne=result
  40.     'COL('i')'; colonne=result
  41.     'WIDTH('i')'; largeur=result
  42.     select
  43.     when alignement = 1 then do
  44.         if ligne<ligne_base then ligne_base=ligne
  45.     end
  46.     when alignement = 2 then do
  47.         if ligne>ligne_base then ligne_base=ligne
  48.     end
  49.     when alignement = 3 then do
  50.         if colonne<colonne_base then colonne_base=colonne
  51.     end
  52.     otherwise do
  53.         if colonne+largeur>colonne_base then colonne_base=colonne+largeur
  54.     end
  55.     end
  56.     'NEXTSEL('i')'; i=result
  57. end
  58.  
  59. if objets<2 then do
  60.     if fr=1 then 'MESSAGE("Sélectionnez au moins"+CHR(10)+"deux éléments avant"+CHR(10)+"d''appeler ce script")'
  61.     else 'MESSAGE("Select two objects"+CHR(10)+"or more before"+CHR(10)+"calling this script")'
  62.     exit
  63. end
  64.  
  65. 'CD='colonne_base':O=FIRSTSEL'; i=result
  66. if alignement=4 then do
  67.     'SAVEALL:O=FIRSTSEL:WHILE(O,MOVE(O,CD-COL(O)-WIDTH(O),0):O=NEXTSEL(O))'
  68.     exit
  69. end
  70.  
  71. 'SAVEALL:O=FIRSTSEL:WHILE(O,IF(ALIGNEMENT<3,MOVE(O,0,'ligne_base'-LINE(O)),MOVE(O,'colonne_base'-COL(O),0)):O=NEXTSEL(O))'
  72.  
  73. exit
  74.  
  75. /* Traitement des erreurs, interruption du programme */
  76. syntax:
  77. erreur=RC
  78. if fr=1 then 'MESSAGE("Script Aligner.AmiCAD"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  79. else 'MESSAGE("Script Aligner.AmiCAD"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  80. exit
  81.  
  82. error:
  83. if fr=1 then 'MESSAGE("Script Aligner.AmiCAD"+CHR(10)+"Erreur en ligne 'SIGL'")'
  84. else 'MESSAGE("Script Aligner.AmiCAD"+CHR(10)+"Error in line 'SIGL'")'
  85. exit
  86.